package com.sword.pay.alipay.adapt;

import com.sword.common.bean.Result;
import com.sword.pay.bean.bo.PayOrder;
import com.sword.pay.bean.bo.PayParam;
import com.sword.pay.bean.enums.ChannelPayEnum;
import com.sword.pay.repository.AbsPayDriverStrategy;
import com.sword.pay.repository.config.ISPayClientConfig;

/**
 * @description: 阿里支付实现适配 多线程下不安全，需要做非单例模式注入
 * @author：Lv.RJ
 * @version: 1.0.0
 * @create: 2025/02/18
 **/
public class AliPayDriverStrategyDefaultImpl extends AbsPayDriverStrategy {
    @Override
    public Result doHandler() {
        ISPayClientConfig payConfig = this.getPayConfig();
        PayOrder order = this.getOrder();
        PayParam payParam = this.getPayParam();
//        Result pay = AliPayFacade.pay(order, (AlipayParam) payParam, (AliPayConfig) payConfig);
//        System.out.println("线程Id："+Thread.currentThread().getId()
//                +"   线程名称："+Thread.currentThread().getName()
//                +"   type："+this.getOrder().getAppId()
//        );
        System.out.println("type："+this.getOrder().getAppId());
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return Result.succeed(this.getOrder().getAppId());
    }

    @Override
    public String getChannelCode() {
        return ChannelPayEnum.ALIPAY.getCode();
    }
}
